package animator.phantom.renderer;

/*
    Copyright Janne Liljeblad

    This file is part of Phantom2D.

    Phantom2D is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    Phantom2D is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with Phantom2D.  If not, see <http://www.gnu.org/licenses/>.
*/

import org.w3c.dom.svg.SVGDocument;
import org.apache.batik.transcoder.image.ImageTranscoder;
import org.apache.batik.transcoder.TranscoderOutput;
import org.apache.batik.transcoder.TranscoderException;
import java.awt.image.*;
import java.awt.Rectangle;

//--- Renders SVG on BufferedImage
public class SVGToBufferedImageTranscoder extends ImageTranscoder 
{

	protected BufferedImage bufferedImage;
	
	public SVGToBufferedImageTranscoder(){}

	//--- Inner working of ImageTranscoder?
	public BufferedImage createImage(int width, int height)
	{
		return new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB);
	}

	public void writeImage(BufferedImage img, TranscoderOutput output)
		throws TranscoderException 
	{
		bufferedImage = img;
	}

	public BufferedImage getBufferedImage() 
	{
		return bufferedImage;
	}

	public void setDimensions(int w, int h) 
	{
		hints.put(KEY_WIDTH, new Float(w));
		hints.put(KEY_HEIGHT, new Float(h));
		hints.put(KEY_AOI, new Rectangle( w, h) );

	}

}//end class
